package com.xiaoxi.exam.controller;

import cn.xinzhili.xutils.core.http.Response;
import com.xiaoxi.exam.bean.response.BannerListResponse;
import com.xiaoxi.exam.model.Banner;
import com.xiaoxi.exam.service.BannerService;
import com.xiaoxi.exam.utils.BannerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/banner")
@Api(description = "banner相关接口")
public class BannerController {

  @Autowired
  private BannerService bannerService;

  @ApiOperation(value = "获取banner列表", notes = "获取banner列表")
  @PostMapping
  public Response getBanners() {
    List<Banner> banners = bannerService.getBanners();
    BannerListResponse response = new BannerListResponse();
    response.setBannerInfos(BannerFactory.toList(banners));
    return Response.instanceSuccess(response);
  }

}
